package vn.fpt.fsoft.action.admin;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.springframework.web.struts.DispatchActionSupport;

import vn.fpt.fsoft.bl.ManageUsersBL;
import vn.fpt.fsoft.entity.AdminAccountInfo;
import vn.fpt.fsoft.entity.UserAccountInfo;

public class ListAdminAction extends DispatchActionSupport {
	public ActionForward listAdmin(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		ManageUsersBL manageUserBL = (ManageUsersBL) getWebApplicationContext()
				.getBean("ManageUserBL");
		DynaActionForm dynaAdminListForm = (DynaActionForm) form;
		List<AdminAccountInfo> list = null;
		list = manageUserBL.getAdminList();
		dynaAdminListForm.set("adminList", list);
		return mapping.findForward("list_admin_success");
	}

	public ActionForward listContributer(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		ManageUsersBL manageUserBL = (ManageUsersBL) getWebApplicationContext()
				.getBean("ManageUserBL");
		DynaActionForm dynaAdminListForm = (DynaActionForm) form;
		List<AdminAccountInfo> list = null;
		list = manageUserBL.getContributerList();
		dynaAdminListForm.set("adminList", list);
		return mapping.findForward("list_admin_success");
	}

	public ActionForward listMember(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ManageUsersBL manageUserBL = (ManageUsersBL) getWebApplicationContext()
				.getBean("ManageUserBL");
		DynaActionForm dynaAdminListForm = (DynaActionForm) form;
		List<UserAccountInfo> list = null;
		list = manageUserBL.getMemberList();
		dynaAdminListForm.set("memberList", list);
		return mapping.findForward("list_user_success");
	}
}
